﻿@using Webs.Models
@model Webs.Models.SearchBillModel
@{
    ViewBag.Title = @SharedRes.SharedString.Search;
}
<div class="PageTitle">
    @ViewBag.Title
</div>
@if (ViewBag.ErrMsg != null)
{
    <div id="dErrMsg" class="ui-state-error ui-corner-all" style="margin-top: 5px; padding: 5px;
        font-size: .9em;">
        <p style="vertical-align: top; margin: 0; padding: 0;">
            <span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
            <strong>@ViewBag.ErrMsg</strong>
        </p>
        <div style="margin-left: 23px;">@Html.ValidationSummary(false, "Please correct the errors and try again:")</div>
    </div>
}
@using (Html.BeginForm("Search", "Bill", FormMethod.Post, new { enctype = "multipart/form-data", autocomplete = "off" }))
{  
    <input type="hidden" id="hBillNo" />
    <table border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td width="230px">
                <div class="editor-label">
                    @SharedRes.SharedString.FromDate
                </div>
                <div class="editor-field">
                    @Html.TextBoxFor(m => m.FrDate, new { Class = "editor-field-col date" })
                </div>
            </td>
            <td>
                <div class="editor-label">
                    @SharedRes.SharedString.ToDate
                </div>
                <div class="editor-field">
                    @Html.TextBoxFor(m => m.ToDate, new { Class = "editor-field-col date" })
                </div>
            </td>
        </tr>
        <tr>
            <td width="120px">
                <div class="editor-label">
                    @BillRes.BillString.BOOKINGNO
                </div>
                <div class="editor-field">
                    @Html.TextBoxFor(m => m.BookingNo, new { Class = "editor-field-col" })
                </div>
            </td>
            <td width="120px">
                <div class="editor-label">
                    @BillRes.BillString.BILLOFLOADINGNO
                </div>
                <div class="editor-field">
                    @Html.TextBoxFor(m => m.BillOfLoadingNo, new { Class = "editor-field-col" })
                </div>
            </td>
        </tr>
        <tr>
            <td>
            </td>
            <td>
                <div class="editor-label">
                    <input type="submit" id="btnSearch" class="btn" value="@SharedRes.SharedString.Search" />
                </div>
            </td>
        </tr>
    </table>
}
<br />
@if (@ViewBag.Search != null)
{
    <table border="0" cellpadding="0" cellspacing="0" class="list-table">
        <tr>
            <th class="first" width="50px">
                @SharedRes.SharedString.No
            </th>
            <th width="120px">
                @BillRes.BillString.BOOKINGNO
            </th>
            <th width="140px">
                @BillRes.BillString.BILLOFLOADINGNO
            </th>
            <th width="360px">
                @BillRes.BillString.SHIPPEREXPORTER
            </th>
            <th width="360px">
                @BillRes.BillString.CONSIGNEE
            </th>
            <th>
            </th>
        </tr>
        @{
           int i = 1;
           foreach (Search_BillResult b in ViewBag.Search)
           {
            
            <tr>
                <td class="first right">
                    @i
                </td>
                <td valign="top">
                    @b.BookingNo
                </td>
                <td valign="top">
                    @b.BillOfLoadingNo
                </td>
                <td valign="top">
                    @b.Shipper
                </td>
                <td valign="top">
                    @b.Consignee
                </td>
                <td valign="top" class="last">
                    <a href="@Url.Action("Edit", "Bill", new { id = b.BillNo })" class="lnkBtn" style="color: White">
                        @SharedRes.SharedString.Edit
                    </a>
                    <br />
                    <a href="javascript:void(0);" class="lnkBtn lnkPrint" style="margin-top: 5px; color: White" BillNo="@b.BillNo">
                        @SharedRes.SharedString.Print
                    </a>
                </td>
            </tr>
                   i++;
           }
        }        
    </table>
    
    <div id="dPrint">
        @Html.Partial("_PrintOption")
    </div>
    
    <script type="text/javascript">

        $(document).ready(function () {

            $("#dPrint").dialog({
                autoOpen: false,
                title: "@SharedRes.SharedString.PrintOption",
                width: 240,
                height: 160,
                modal: true,
                resizable: false,
                buttons: [{
                    text: "@SharedRes.SharedString.Print",
                    click: function () {
                        $(this).dialog("close");

                        var link = '@Url.Action("Print", "Bill")' + '/' + $("#hBillNo").val();

                        if ($(chkOption).is(':checked'))
                            link += "?layout=false";
                        else
                            link += "?layout=true";
                        window.open(link);
                    }
                }, {
                    text: "Cancel",
                    click: function () {
                        $(this).dialog("close");
                    }
                }]

            });

            $(".lnkPrint").click(function () {
                $("#hBillNo").val($(this).attr("BillNo"));
                $("#dPrint").dialog("open");
                return false;
            });

        });    //ready
                           
    </script>
}
<script type="text/javascript">

    $(document).ready(function () {


        $('#FrDate, #ToDate').datepicker({ dateFormat: 'dd/mm/yy' });

    }); //ready
    
</script>
